Skip to content

feat: add code block actions, preferred mode, prompt queue, and image/file attachments - #82

Open
tazztone wants to merge 9 commits into
formulahendry:mainfrom
tazztone:feat/chat-ux-enhancements
Open

tazztone wants to merge 9 commits into
formulahendry:mainfrom
tazztone:feat/chat-ux-enhancements

Conversation

@tazztone

Copy link
Copy Markdown

Summary

src/
├── config/ModeResolver.ts         # Resolve acp.defaultMode / saved mode across configOptions & legacy modes
├── core/PromptBuilder.ts          # Build ACP ContentBlock[] (image, resource, resource_link, text) gated by promptCapabilities
├── core/SessionManager.ts         # Apply remembered/default mode on new sessions; pass attachments in sendPrompt
├── extension.ts                   # Multi-select acp.attachFile, globalState persistence, config-options-changed sync
└── ui/ChatWebviewProvider.ts      # Code block Copy + safe terminal paste, unblocked input + prompt queue, image paste/drop/attach
  • Code Block Actions: Wrap rendered <pre><code> blocks with language header, Copy (vscode.env.clipboard.writeText), and Paste to Terminal (workbench.action.terminal.paste bracketed paste with clipboard save/restore so multi-line snippets do not auto-execute).
  • Default & Remembered Mode: Add acp.defaultMode (default "auto", applied when supported by agent) and acp.rememberMode (default true, persisted per agent in globalState).
  • Unblocked Input & Prompt Queue: Keep #promptInput editable during active turns/compaction, queue on Enter / Queue button instead of cancelling, persist draft/queue across view switches, and auto-dispatch queued items on non-cancelled/non-error promptEnd.
  • Image & File Attachments: Honor agentCapabilities.promptCapabilities (image, embeddedContext), update webview CSP (img-src data:), fix acp.attachFile (attachmentsAdded), support clipboard image paste + drag-and-drop, and render user attachment previews and user_message_chunk replay blocks.

Evidence

  • Before:
    • npm test: 3 baseline tests passing; no ModeResolver or PromptBuilder tests; file-attached had no webview listener; #promptInput locked during turns (promptInput.disabled = true).
  • After:
    • npm run pretest (tsc -p . --outDir out, webpack, eslint src --max-warnings 0): exited 0 (0 warnings).
    • npm test (VS Code 1.146.0 Electron Mocha runner): 8 passing:
      • Extension should be present
      • Should activate extension
      • Should register ACP commands
      • Default mode configuration defaults
      • resolvePreferredModeId handles flat and grouped configOptions
      • resolvePreferredModeId handles legacy modes
      • getImageMimeType detects supported image extensions
      • buildPromptContentBlocks enforces image capability and resource fallback

Merge Danger

Door: Two-way

Additive UX/protocol features and settings (acp.defaultMode, acp.rememberMode); setting acp.defaultMode: "" disables automatic mode selection while keeping per-agent mode memory optional.

Blast Radius: Low

Scoped to ChatWebviewProvider, SessionManager, extension.ts, two new pure helper modules (ModeResolver, PromptBuilder), package.json, README.md, and src/test/extension.test.ts. Does not alter acp.agents defaults (kept independent of #81).

@tazztone

Copy link
Copy Markdown
Author
image image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved session-isolation and submission-state bugs can send queued prompts and attachments to the wrong session or silently discard submitted prompts.

7 open issues
What changed in this PR

This PR expands the ACP chat experience with code-block actions, preferred execution modes, queued follow-ups, and capability-aware attachments. Agent presets remain unchanged, separate from #81.

Changes:

  • Add code-block Copy and terminal-paste actions, editable input during turns, and a persistent prompt queue.
  • Resolve default or remembered modes and persist selections per agent.
  • Build attachment-aware prompts, support image paste/drop and file selection, and add helper tests.
File Description
src/​ui/​ChatWebviewProvider.ts Adds code actions, queuing, draft persistence, attachment handling, and previews.
src/​test/​extension.test.ts Tests mode defaults, mode resolution, and attachment content construction.
src/​extension.ts Wires preference storage, configuration updates, and multi-file selection.
src/​core/​SessionManager.ts Applies preferred modes and sends capability-aware attachment prompts.
src/​core/​PromptBuilder.ts Converts text and attachments into ACP content blocks.
src/​config/​ModeResolver.ts Resolves preferred modes across configuration options and legacy modes.
README.md Documents the new chat features and mode settings.
package.json Registers default-mode and remembered-mode settings.

Review effort: Balanced

Comment on lines +2842 to +2848
hasActiveSession &&
!isLoadingSession
) {
const nextItem = queuedPrompts.shift();
saveState();
renderQueuedPrompts();
dispatchPrompt(nextItem);
return ci ? ci.value : null;
}

const available = modes?.availableModes;
Comment thread src/ui/ChatWebviewProvider.ts Outdated
Comment on lines +155 to +158
if (previousClipboard) {
setTimeout(() => {
void vscode.env.clipboard.writeText(previousClipboard);
}, 150);
Comment thread src/ui/ChatWebviewProvider.ts Outdated
Comment on lines +211 to +212
if (this.isPromptRunning) {
return;
Comment on lines +1533 to +1535
draftText: promptInput ? promptInput.value : '',
queuedPrompts,
promptCapabilities,
Comment thread src/ui/ChatWebviewProvider.ts Outdated
});

promptInput.addEventListener('input', () => {
saveState();
Comment thread src/ui/ChatWebviewProvider.ts Outdated
const MAX_TEXT_BYTES = 256 * 1024;
const attachments: PromptAttachment[] = [];

for (const uri of uris) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants